<template>
	<view class="content">
		<view class="panel-header solids-bottom padding-bottom-xs">
			<text class="panel-title text-xl text-bold">自我评价</text>
			<text class="panel-edit text-df text-blue"><a @click="editData()">{{edit ? '[保存]' : '[编辑]'}}</a></text>
		</view>
		<view class="panel-content">
			<view class="panel-item text-lg padding-xs solid-bottom">
				<view :class="edit ? 'bg-gray' : ''">
					<view v-if="!edit" class="word-warp">{{memo.length == 0 ? "(空)" : memo}}</view>
					<view v-if="edit">
						<textarea class="text-left" v-model="memo" maxlength="300" />
					</view>
					
				</view>
				<view class="text-right" v-if="edit">{{memo.length}}/300</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				edit: false,
				memo: ''
			}
		},
		created() {
			this.getData();
		},
		methods: {
			editData() {
				if (this.edit) {
					this.edit = false;
					var memo = this.memo;
					uni.post("/api/resume/SaveMemo",{memo},msg => {
						uni.hideLoading();
						if (msg.success) {
							uni.showToast({
								title: '保存成功'
							});
						} else {
							uni.showToast({
								title: msg.msg,
								icon: 'none'
							});
						}
					});
				} else {
					this.edit = true;
				}
			},
			getData() {
				uni.showLoading();
				uni.post("/api/resume/GetResume",{},msg => {
					uni.hideLoading();
					if (msg.success) {
						this.memo = msg.basic.Memo;
					} else {
						uni.showToast({
							title: msg.msg,
							icon: 'none'
						});
					}
				});
			}
		}
	}
</script>

<style>
	.panel {
		/* width: 100%; */
		margin: 10px;
		padding: 10px;
		height: auto;
	}
	
	.panel-header {
		display: flex;
		flex-direction: row;
		align-items: baseline;
		justify-content: space-between;
	}
	
	.word-warp {
		word-wrap: break-word;
		word-break: break-all;
		overflow: hidden;
	}
	
	.border-bottom {
		border-bottom: #eeeeee solid 1px;
	}
</style>
